package com.tsmask.bound;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JLabel;

/**
 * 城市信息栏组件
 * 
 * @author TsMask
 *
 */
public class CityInfoBound { 
	// 各状态为
	// youxiu #33c704
	// liang #ffc000,
	// qing #db7e06,
	// zhong #a71811,
	// zhongdu #8f08bb,
	// yanzhong #9a1c8d,
	private Color airState[] = { 
			new Color(51, 199, 4),
			new Color(255, 192, 0),
			new Color(219, 126, 6),
			new Color(167, 24, 17),
			new Color(143, 8, 187),
			new Color(154, 28, 141)};
	
	private int aqiLevel[][] = { 
			{0, 50},
			{50, 100},
			{100, 150},
			{150, 200},
			{200, 300},
			{300, 1000}};
 
	private String alertMap[][] = { 
			{"youxiu", "空气优"},
			{"liang", "空气良"},
			{"qing", "轻度污染"},
			{"zhong", "中度污染"},
			{"zhongdu", "重度污染"},
			{"yanzhong", "严重污染"}};

	/**
	 * 天气城市名称组件
	 * 
	 * @param city 城市名称 上海
	 * @return 标签组件
	 */
	public JLabel wetherCity(String city) {
		JLabel jLabel = new JLabel(city);
		jLabel.setBounds(24, 70, 180, 30);
		jLabel.setForeground(Color.WHITE);
		jLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 32));
		return jLabel;
	}

	/**
	 * 天气发布时间组件
	 * 
	 * @param timeStr 时间字符串 13 : 33
	 * @return 标签组件
	 */
	public JLabel wetherTime(String timeStr) {
		JLabel jLabel = new JLabel(timeStr + " 发布");
		jLabel.setBounds(24, 100, 80, 30);
		jLabel.setForeground(Color.lightGray);
		jLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
		return jLabel;
	}

	/**
	 * 天气发布时间组件
	 * 
	 * @param air 空气质量 空气良 82
	 * @return 标签组件
	 */
	public JLabel wetherAir(Integer aqi) {
		JLabel jLabel = new JLabel();
		// 比较aqi值范围
		for (int i = 0; i < aqiLevel.length; i++) {
			if (aqi >= aqiLevel[i][0] && aqi < aqiLevel[i][1]) {
				jLabel.setText(alertMap[i][1] + " " + aqi);
				jLabel.setBackground(airState[i]);
				break;
			}
		}
		jLabel.setHorizontalAlignment(JLabel.CENTER);
		jLabel.setBounds(24, 128, 120, 28);
		jLabel.setForeground(Color.WHITE);
		jLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
		jLabel.setOpaque(true);
		return jLabel;
	}
}
